my old RBM code