calculation errors fixed