Fix crash on just hitting tab

Just hitting tab crashed the repl
took opportunity to switch/case the completer code so more readable.