fix exception in register funcion