Move query logic out of style element