uplate.php refactoring