code refactoring - adding functions to closure and removing check for jQuery as I've moved it to being added to the head in the node code