You can move this check behind the condition on line 119. Currently, if the condition on L119 passes but the condition on L120 fails, the update isn't done even though you log that it is.