minimized code spacing and moved {}  on if/else statements and functions to make code more readable.