redid statemeachine to extend eventemitter and linted