Adding event code to top and flop