#2834 improved code