weakly dominent code
refactor to remove duplicate code
refactor to remove duplicate code