moved if-else on the same line as previous closing brace
simplified some if-else blocks