redid pattern matching and added tuples