Restructured interface of getEvents function