make loop more efficient