add comments and removed unused code