finish the registration function