IMPROVED: refactoring with new compat.py