Refactoring for easier explanation and adding custom providers