removed some structures out of loops