Refactored Code to make more like 1) State pattern 2) Component Pattern