commented and cleaned up code.