Fix bug with wrong variable