refactored removal of colorbar into function