added query implementation