Check if data is empty before looping over it
Updated more object property checks
Added isset check before iteration
Minor code formatting
Updated more object property checks