Refactoring resource form code