added checks for square numeric matrix, changed set