old RBM code