Refactoring code for new factory pattern with storage providers