refactor compute.py