Fixed bug with rate calculation