Setting a variable inside a if statement does not work... moving it outside.