added more type checking to primitives