Refactor primitive matching to use simpler equivalent statement