changed to emit ready event