added some optimizations to example 1