Fix error in calculations