fixed #32 and #31