Added error handling at register