refactore key and index