template array searching for mode function