the code shows an error when the no. of rows in the range is lesser than 500 rows, how to correct it, thank you