created functions to add event listeners