Converted query to use bufs