try to add a memory mechanism, not finished yet