Factor out REPL