Refactor tooltip logic into new file