pattern matching is not working at all like it should