coding style: less nesting; standardize spacing between functions