Improving Algorithm

Signed-off-by: fisherjk <John@John-PC>