code snipts for id refinement