amended query syntax to be compatible to both types of models