update some stuff copied from ML lecture notes