Fixing databse count array and iteration.