Found and fixed bug in calculation