No functionality change, only re-factor cleanup to avoid deep nesting

* tested on iPhone/iPad, android desktop Chrome & Firefox & Safari