added example. small code cleanup, too