added flow logic for reference