tweaks to mode function