updated code examples and restructued