Fix Notices error - Trying to get property of non-object in ...