refactored to use new REST APIs