Change comparison to avoid redundant variable reset