fixed buf length issue