refactoring small changes, changed event function structure