add comments and fix indentation