Added most of the error checking for createUser