Corrections on Js logic