Revert "Simplified code and updated formating"

This won't work if there's an `afterOpen` specified, as the extend will overwrite the one in the config.

This reverts commit f88f2c675cad53b8ba3a9a5880de44e2d768caba.