refactor for code sharing