cleaned up a bit and prepared the event add function