SNN ALGORITHM