code formatting and optimization