refactor for reuseability