parameter learning, first-pass. might need debugging