Refactor roid query