Added comment and refactored code