more or less working stand alone version