The state design pattern