A bit more error checking