fixed undefined variable errors