Optimizing php code, removing unneed php if statement by incorporating it into the first if statement