Improve JS justify function.