modified the function