Fix error checking functions