reuse code in views