Refactor use of old api