forgot to add min() thing in get cost
small edits