Clean up pure js sol'n, use self calling anonymous function