added callbacks to query and getbyid