refactor pattern matching in tuples