performance improvement for #248