working generic pick and set function