Issue with "non-existent variable" error