Name refactoring
Minor refactoring
Put the brace-shifting code into a method
Code explanation and formatting