added comments/small refactoring