better performance fix for #269