Added commenting for code readability