Refactored REPL