Added merging of table rows with necessary logics.