using literal obj in doc; removing explicit null/undefined check; and simplifying the JSON.stringify()