added a universal type checking function