better checking for undefined states