changed the type_check to be more pythonic