Extract repl loop