new functions, and added max/min with date