Added min and max functions