remove duplicated code in repl