Refactor providers logic