Refactoring REPL