Fixing register function