Fix register function