Adding min and max functions