Refactor for testing