refactor: use Active Pattern