bug fixed in original provided code