fix minimize bug (another improvement still needed)