Added logic to insert rows