templates refactored, event delegation used