changed type checking code to not suck