same lua code apart from events.run