fix the bug of segment fault