Refactor to avoid PHP warning