fixed a bug, improved the accuracy of calculations