logic to allow flat or nested params