function-based pattern matching is re-written into regular one
week3 challenge problem - correct types aggregation algorithm