add some comments and cleaning up