refactor pairing task logic