implement #1499 and #1489