solution 11: replacing guard by pattern matching