Implement bounds check in submat and extract