added many optimizations
updated optimizations