fix algorythm, bad optimization
add an optimization on jajascript
clean code