Updated register function