Refactor for speed