refactor into provider pattern