removed excessive code and changed some comments