Last fix didn't work, program still crashed. Will try returning True rather than False in on_data()