Refactor sdk.py