Added filterWithIndex method as alternative to filter method