refactor the resources system