refactored code, removed excessive comments