fixed bug mentioned by Felix for #45 and #52