speeding up minimize