refactoring handling of missing values