php: refactoring