my alternate solution for challenge #8 without using pipes