moving logic out of views