Reverted to old program loop as the new one worked in unexpected ways.