Added the last of the besic logic to avoid all walls