Added maximize and minimize functions