first working variant. close #40