added comment and fixed minor issues