edit cost function