Added auto-cost function