backend function for upcomming and previus events