images need to be sorted first