update and optimizations