Refactor for performance