updated select function to be general about UID length