Fixing bug in the register method