refactor to resource