new function to processing the last row