refactor finding and setting contact group into their own functions