minor changes in the function