Refactor checkConflict for better efficiency