Added support for custom queries