I will try to refactor to use state machine during the weekend.