better key parsing