Fixed "Property of Non-Object" Error

Unsure if the is_null on line 19 is absolutely necessary.