refactor for stability