fixing bug in character reading - did not include case for query
fixing cast to wrong class