Refactor for generalizing