Fixing algorithm to shift all characters in array