DJR:Added check for nodejs so code runs correctly in browser