write collect_method as instance method of class Array