Refactoring in line with latest API update