Did some more error checking