ranking code started, needs formula and db retrieval