edited register function