Cleaning up some syntax errors and adding stop conditions