Refactoring to use resources