I found it a bit difficult to see where this if is finished. Maybe add braces? I suggest we use if without braces only for one-liners without else.