separate out populate dialog function