added comments, removed unused code