calculate index for all directions
works
done