Replaced quick hack with real list iteration