first, probably non-working version involving a lot of guesswork