fixed a bug in the if-statement and a typo

Fixed a bug that incorrectly checks `rowspan` and `colspan` out of bounds conditions.
`Incorrect parameters: colspan or rowspan out of bounds`