Updated to include additional comments in the function