Js refactors for speed