Structure optimization (step 3)