Added commenting for each function