Modified new algorithm