added query processing
changed function naming convention + misc. fixes