updated to use a more robust way of reading post datawhich also assigns a default value if not set. Thanks B for pointing this out!