Structure optimization (step 2)