cleaner logic for creating a match