some useful piece of js code