re-added accidentally deleted code from previous merge