Algorithm 004 improved