Added wrapper if statement to check the row count