added comments + small refactoring