enhance and modularize REPL