add conditional callbacks, detect first line received from device