adding event variables to functions