faster __mode function