Correct type checking of functions