added sql command to update average rank