added more events, moved math around