Fix some syntaxical nonsense.

Function doesn't need to be in variables and nested if is unnecessary if there is no alternative.