Added exception handling to gem