added a few more optimizations