correct some mistakes in code that Antony pointed out