adding better comment to explain the function logic