Reversed if-statement again due to undefined index