Refactored using a backend and dependency injection