trying to fix compute_cost()