implemented error handling in upgrade mechanism