bug fixes by catching errors