handle setting $data to null