Fixing PHP warning simplyfing code with function.
Minor - format code