adding the bulk of the repl code