added function for register when success