added row/col-span logic + minor bug fix