refactored to reduce duplicate content
added documentation
merged
fixed up examples