fixed case when query return nil