Proper handling of API errors added