added state pattern