moved listeners to their own function