add some performance improvements
add cache option