added better optimization on images and switched references