Query copying in controllers and added query template