Changing JS to singleton name spaced pattern