Refactoring (dependency injection + promises)