refactor to do some code sharing for static views