fixed undefined variable check, fixes #1