Add Input checking

verify matrix size and values