adding reference selection function