added loading animation and better error handling