finished register function