small fix in the image picking algorithm