Move some functions to global js