Fixing wrong variable setting