Updated JS for Maximize and Minimize functions.