methode with the two nearest planes implemented