fixing issues #30 and #46