remove duplicate local var; remove unnecessary comparison with both null and undefined