added padMatrix() function