implemented a self-learnign rewrite model
implemented a self-learning model