Added more verbose error checking