updated implementation of RNNs