put closing div tag in the correct place