fixed some oddities in the calculation