Added algorithm main loop plus preprocessing commands