Refactor getData() method