slight refactors, made it an event emitter