refactor resource system