1. Practice commands and drills that you are working on, on every walk, not just when you need your dogs attention because that is when it is too late.
2. Set boundaries and teach the dog their limitations otherwise they wont understand what they can and cant do, eg when they head off the trail, stop them and say 'this way' , when they get too far ahead of you say 'stay close' and stop them from going any further each time they approach that boundary.
3. Start training on leash, then use a long line to make sure the dog cannot ignore you and so you can teach them that there is no other option to run off and sniff something or to take off with another dog
3. Practice recall commands on EVERY WALK, this one is important, and ALWAYS release the dog back to what they were doing by saying 'ok' and don't always use a recall command when its time to go home or clip the leash on, try other commands such as this way or' find it' (throw a treat on the floor for the dog to find) so the dog cant predict what the outcome will be and your recall command stays strong.