Works for real except for the halting condition