change advance-fhead! to wait for data as needed