Tweaked for use on later versions of NodeJS