small changes in main plus added chapter 3