added code to calculate rate from Rate class but  not working yet.