type checking for function return