cleaned up code and added pagination to event table