switched to `typeof` method for checking for `undefined`