fixing bug with direction changing
fixing bug with loop constuction in analyzer