Enforced proper bounds on indices of vector
From rvalue to lvalue for ->total_cost