not quite sure if this will help, But have you tried
if angle = 0 (then pick 90,180,270)
if angle = 90 (then pick 0,180,270)
if angle = 180 (then pick 0, 90,270)
if angle = 270 (then pick 0, 90,180)
edit: also use marker blocks top,bottom,right,left if overlapping top on collision with right angle go down or left (pick 180,270) and so on. so not to get stuck in a corner just going top and right.
As we can not see what you have done it is hard to point you in the right direction, without guessing at the issues you are having.