variable assigned wrong value