refactor for performance