handle missing values in different stages