refactor 2nd parameter type check