adjust to use c++11 loop