Cleaned up solution for puzzle #2