replaced BOOST_FOREACH with for