Modified the script so it doesn't go into infinite loop when the program continuously fails to reach the goal size