added elements to example
refactored code