implemented writeRegister