made a correction to the function and added comments