Commiting the new SOS code that works for any array size and also acheives high performance