Fixed bug with new function query