Make code more robust to inconsistence keyspace condition