add comments and clean up