Added State Machine and More Definitions