incorporated event delegation and a bit of clean up