added a check that the types match
Implemented most of match and case, tuple remains