code commented and cleaned