Improved alteration algorithm