now taking 2nd matrix too