fix #528 and #529