Add some additional error checking