Modidified Gem File to handle error