Fixed bug caused by undeclared variable