refactoring to IndexedSeq
first attempt at Challenge 6, still broken