fix for #18 and #6