Move query definitions out of controller