Fixed comments and handled exceptions