moved over scripts for main algorithm