add eventemitter and error handling