moved some code into toolbar.