Added REST API for costs and correct algorithm