ops.py refactoring