js improvement
some useful functions