Few Optimizations to code