Debuggin and new logic flow