Your code examples would be easier to read if it used standard indentation to reflect the logic.