fix bug of computing displacement