used delegated events and added a minified version