Some useful code, function javascript