small refactor and fix