Fix logic in key/value store retrieval