fix for potential error in nested keys code