Refactored the main code so I can easily run different algorithms