optimization with limits