Implemented proper selection of elements to refine.