Separate listener into a separate function