replace type checking with callable global function