Fix bug, wrong variable was used