corrected flow diagram