added wrapper and edited minimize function.