added scale matrix function