refactored the query options code to its own helper to refactor it and decouple from helper code.