Repaired bug where key is not returned correctly