fix for #188 and revised fix for #186