fixed maintain_scores to work with mysql