intial commit from sample with some hackery to get it working