Fixed some issues with the calculation