Added commenting and removed redundancies