fix ##282 and #158