added an extended version with some helper functions