This is the algorithm that could save elephants from extinction