improve SetRate function