Fixing minor bug with event being attached to nested elements