Improve flow and debug