Completely misunderstood this simple problem. Committing the code for future use.