some reformatting and solution of assignment 4