modified basic algorithm. clean codes and used function.