Removed complex solution, and replaced it with a simple, for-based one