added data check on event handler