added rate function and unit test