code comment and tidying