added more structure and comments