refactor to use Resource class