Added the computeCosts logic.