moved view logic into a function
moved generial view function into shared module