refactor loadResource() method