fixed undefined variable error