Updated to use event delegation