refactored php code docu