Added code to deal with NAs after extracting covariates from env.dir