it doesn't belong in the view, that is sure. See the new commit, I moved out the logic from the view