fixed undefined check