add comment and small refactoring