Modify trace function