aligning cast added
swapping arrays added and tested