Added more error checking to POST