code is a bit messy, but the basics are there. Next is to create specific emitter functions