fixed example error
code optimizations