Added the corresponding else block.
Extracted ugly class.