reformat converting tabs to spaces and alignment
added isset 
and brackets to if statements