add cost fn