refactored php, fixed bug with attribute editing