Adding some optimizations