code clean-up
moving code out of views