Added some comments and cleaned the code of previous commit