rewrote updatecosts