added examples
slight optimizations