changed code type checking to macros