Working self.by_market function