refactored resource code