Maybe put this if block above the $subpage = $this->getSubpage() line so it doesn't drive a wedge between when this variable is initialized and when its used.