Refactoring grouping of wells