Homework 5.2 done and tested