refactors a bunch of the history code into input view, also saves history to userstate