solar coronal plasma. Detailed insights into the coronalmagnetic field are important to understand most of the physicalphenomena there. While direct routine measurementsof the coronal magnetic field are not available, field extrapolation ofthe photospheric vector field measurements into the corona is the onlyway to study the structure and dynamics of the coronal field. Herewe focus on global coronal structures which are traditionally modelledusing spherical grids and synoptic vector magnetograms asboundary conditions. We developed a new code that performs nonlinear force-freemagnetic field extrapolations in spherical geometry.Our new implementation is based ona well-established optimization principle, which was implemented on aCartesian grid and a single spherical finite-difference grid.In the present work, for the first time, thealgorithm is able to reconstruct the magnetic field in the entirecorona, including the polar regions. The finite-differencenumerical scheme that was employed inprevious spherical code versions suffered from numerical inefficienciesbecause of the convergence of those grids on the poles. In our new code,we implementthe so-called Yin-Yang overhead grid, the structure of which addressesthis difficulty. Consequently, boththe speed and accuracy of the optimization algorithm are improvedcompared to the previousimplementations. We tested our new code using the well knownsemi-analytical model (Low and Lou solution), which has frequently been used as a benchmark for nonlinear force-free extrapolation codes.