perhaps check for empty key instead? And make this a helper function instead of copying the logic to two places? Thanks for the fix.