refactor for speed