Trying out finite state machine