updated the function