refactor and add functionality to events page