fixed bug where images array got indexed wrongly