There's no need to check the first and last rows since they'll always be the Favorites and AddDir rows. Also change the name of the clear_all variable for consistency.