Refactor REPL feature