corrected use of variables to ensure ordering.