updating wrong variable