Found a variable name error in addEvent() which was corrected.