finished refactoring & CLI implementation