Cleaned up while loop so that starttask is not called a bajillion times