Refactoring to use official API