migrated globally useful functions to  main.js