added distribute funtion in Matfunctions