change upgrade algorithm