started refactor (CLI working)