Updated Homework  to a better solution.