query and convert functions will remove debug output later when everything works