nit: 

Rest of the code is in the form of

if (cond) { 
  ...
}