Tidied up after code review & added in "asshole" protection (in case somebody overwrites "undefined")