optimizations + formatting