minor fixes to the same function