fix undefined variable issue