error checking for functions