state pattern desing.