php refactoring