refactor release resource and get resource