Fixed installation loop & added proper error handling