fixed undefined bug