new updated version with basic obstacle avoidance