fixed undefined variables check