addded commentary, removed unused code