some blank lines, removed ternary operators

The ternary operators were nearly unreadable. Removed them.
removed nested if-else construct

Removed nested if-else construct and replaced it with a combined if condition.