fixed variables error; variables can not be used inside functions