additional optimizations and formatting