fixed the comparison code so the cost calculations are correct, finally