Added Query code