fix #31 and #36