Fix bug in east-west transition. Added out-of-bound check