fixed undeclared variable error