add buffered read function