built popularity algorithm in contoller