update mat apply functions, a few utils