tweaked multi-image algorithm