Enclose contents = NULL in the conditional block so as to avoid unnecessary updates and to avoid future problems.