Added braces to if/else
Guessed on code setting to get passed error
Made view a default null to get past hard error when null is getting sent to it.
comment added