Addind some error handling for stability