Optimize Wave olgorythm using bit shifting