put all function into one namespace, refactored (no jslint issues)