Added error checking to registration