added so coments to help understand the flow