Added min and max functionality