Rearrange repl function a little