added event listener and functions