Fix error in looping databases.