merging some of phil's example