Deep nesting of control structures is a good indicator for a code smell. You should refactor this code into smaller methods with speaking names.