Yes, declaring the variable solved my problem.
Thanks for the help.