so are you asking at what event should you use the above code.