optimized the code for minimal object creation