updated register function