fixed std::out_of_range bug