fixed the register function.