simplified to use easy but inefficient buffer reading