fix buf nullpointerexception , add boolean filed to compare