optimize and balance