Better method of doing that, function linked to event