Fix broken key existence check