read from buffer