Replaced array_key_exists with isset
Changed else if to elseif
Reformat code