small refactor and a few comments