Improved nested if statement code formatting