How to avoid horrible nested for loops? | Hacker News Reader