Added min and max functions on boundaries