cleared functions not necessary and attached all of the event handlers.