declare 'value' at the beginning of the function