fixed a wrong calculation