added undefined check to typecast
Merge pull request #29 from Zolmeister/master

added undefined check to typecast