fixed mainImage function bug