add some comments and proper indentation