added some comments and removed unecessary code