Also broke up the listen function into a handle_data function