added the finite state machine thingy -- joe + fendy