factor repl factory into repl module