jslint and use state machine model to handle asynchronous events