refactored resource loader