fix key detection