added rating logic