More robust way to check if the folder is empty