modify function. should work on mac