fixed wrong calculation