commented and cleaned code