Refactor for alembic