refactor prepareDirectTip function