move functionality to event handler