Refactored state pattern to use bstract base class