Please add comments specifying the parameters and corresponding behaviors for this function, thanks!