fixed a bug in the adjacent target optimisation