added example and tweaked API