fixed the bug, now arrow is changing directions correctly.