more or less workign version