state pattern & first refactoring complete