generalize the dirSelect template

now we can use the same template for both the
second and third pass