Replacing wrong variable