Remove logic from view.
Limit use of global variables.