adding in a eventemitter and tests
merging with current code