Logic for optimizing image usage