Refactored to use async/await  for a responsive UI