tools.py: refactor import