Working on list (array) pattern matching