refactore event listeners to combine other functions instead of creating ones