fixed and improved displacement implementation