Made some comments and more understable code