Reduce number of data-ensure loops and variables