fixing bug when loading many images