refactored to reduce duplicate content
added documentation
merged