added flow diagram