removed unnecessary null value
added curly braces to if statement