Simplify code examples

This PR simplified the code examples and improves the consistency.