fix bug of pgdir(the bug that cause the system to crash).