Smart obstacle avoidance