calculating costs