move conflict detection into a class and use it