finish register function