fixed wrong cost calculation