Automate more the algorithm