added flow logic