fixes invalid reference in event listener