slightly updated - this will not work but gives the idea