Added some comments and removed unnecessary code